package com.ruohi.gift.order;

import java.lang.reflect.Method;

import com.ruohi.util.common.CommonString;

public class OrderOperate {
	/**
	 * 显示订单的可用操作
	 * 
	 * @param order_num 订单号
	 * @param operateStr 订单可用操作的字符串
	 * @param operate_source 操作来源，来自前台/后台，值为Front/Back
	 * @return
	 */
	public static String showOrderEnableOperate(String order_num, String operateStr, String operate_source) {
		String rtnStr = "";
		String invokeClassName = "Show" + operate_source + "OrderOperateImpl"; // 要调用的类名
		if (!CommonString.getFormatPara(operateStr).equals("")) {
			try {
				Class classType = Class.forName("com.ruohi.gift.order." + invokeClassName);
				Object instancer = classType.newInstance();
				Class[] parameterTypes = { order_num.getClass() }; //声明调用方法时所传参数的类型
				Object[] args = { order_num }; //调用方法时参数
				String[] operateAry = operateStr.split(",");
				for (String operate : operateAry) {
					Method method = classType.getMethod(operate, parameterTypes);
					Object obj = method.invoke(instancer, args);
					rtnStr += CommonString.getFormatPara(obj);
				}

			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return rtnStr;
	}
	
	/**
	 * 显示订单提示
	 * @param order_num
	 * @param mem_no
	 * @param order_status
	 * @param source
	 * @return
	 */
	public static String showOrderTips(String order_num,String mem_no,int order_status,String source){
		String tips="";
		String invokeClassName = "Show" + source + "OrderOperateImpl"; // 要调用的类名
		try {
			Class classType = Class.forName("com.ruohi.gift.order." + invokeClassName);
			Object instancer = classType.newInstance();
			Class[] parameterTypes = { order_num.getClass(),mem_no.getClass(),int.class }; //声明调用方法时所传参数的类型
			Object[] args = { order_num,mem_no,order_status }; //调用方法时参数
			Method method = classType.getMethod("showTips", parameterTypes);
			Object obj = method.invoke(instancer, args);
			tips = CommonString.getFormatPara(obj);

		} catch (Exception e) {
			e.printStackTrace();
		}
		return tips;
	}
}